package com.raptor.trustworthy.server;

import com.raptor.trustworthy.server.listeners.AppCloseListener;
import com.raptor.trustworthycore.TrustworthyCoreConfig;
import com.raptor.trustworthycore.listener.TrustwothyPreparedListener;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.support.SpringBootServletInitializer;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.EnableAspectJAutoProxy;

@Configuration
@EnableAutoConfiguration
@EnableAspectJAutoProxy//aop切面自动代理
@MapperScan(value = {"com.raptor.trustworthy.server.mapper"})
@ComponentScan(basePackageClasses = {TrustworthyCoreConfig.class, TrustworthyServerApplication.class})
public class TrustworthyServerApplication extends SpringBootServletInitializer {



  private static SpringApplicationBuilder configureApplication(SpringApplicationBuilder builder) {
    return builder
        .sources(TrustworthyServerApplication.class)
        .listeners(new TrustwothyPreparedListener())
        .listeners(new AppCloseListener());
  }

  public static void main(String[] args) {
    configureApplication(new SpringApplicationBuilder()).run(args);
  }

}
